package admin

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"zhuandan/data_source"
	"zhuandan/models"
)

func Banben(ctx *gin.Context) {
	var banben models.Banben
	data_source.Db.Where("id = 1").First(&banben)

	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    banben,
		"msg":     "ok",
	})
	return

}

type BanbenupdateBody struct {
	Banben  string `json:"banben" gorm:"banben"`
	Content string `json:"content" gorm:"content"`
}

func Banbenupdate(ctx *gin.Context) {
	request := BanbenupdateBody{}
	ctx.ShouldBind(&request)
	banben := request.Banben
	content := request.Content
	banbenup := models.Banben{
		Banben:  banben,
		Content: content,
	}
	data_source.Db.Where("id = 1").Updates(&banbenup)

	ctx.JSON(http.StatusOK, gin.H{
		"code":    0,
		"error":   0,
		"success": 200,
		"data":    "ok",
		"msg":     "ok",
	})
	return

}
